/* 
 * File:   State.h
 * Author: chadijir
 *
 * Created on September 26, 2010, 1:42 PM
 */

#ifndef STATE_H
#define	STATE_H

#include "Graph.h"

using namespace std;

/*
 * Here we should keep information about current state in an algorithm.
 * We need to keep track of which nodes are in which group.
 *
 * This we could realize by using a bool array of size n, where node on position
 * i (array[i]) containing TRUE would be a part of set X and those containing
 * FALSE would be part of set Y.
 */
class State {
public:
    State();
    State(const State& orig);
    virtual ~State();

    void init(Graph * gGraph); // sets up underlying structures

    unsigned int getCost() const; // returns cost
    void countCost(); // counts cost by walking through the array
    void setNextNode(unsigned int i); // sets nextNode value
    unsigned int getNextNode(); // returns nextNode value

    friend ostream &operator<<(ostream &out, const State &state);
    State& operator= (const State& aState);
    bool & operator[](int i); // shorthand for accessing array fields

private:
    Graph * graph; // current instance of problem
    bool * array; // array with node information
    unsigned int size; // number of nodes
    unsigned int cost; // cost of cut in this state
    unsigned int nextNode; // which node should be added to set X next time

};

#endif	/* STATE_H */

